<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/commons/global.jsp" %>
<html>
<head>
    <title>Java EE Rapid Development Platform</title>
    <%@ include file="/commons/basejs.jsp" %>

<style>
    .layer{position: fixed;top:0;left:0px;right:0px;bottom:0px;background:rgba(0,0,0,.5);z-index:2}
    .login{
        width: 500px;
        height: 420px;
        position: fixed;
        top:50%;left:50%;margin:-300px 0px 0px -250px;
        z-index:10;
    }
    .login h2{font-size: 30px;text-align: center;color:#fff;font-weight:normal;text-shadow: 6px 5px 10px #000;}
    .login_box{
        width:100%;
        margin-top:50px;
        background:rgba(255,255,255,.6);
        padding:35px 0px 50px;
        border-radius: 5px;box-shadow: 1px 0px 30px 4px #ccc inset;
    }
    .top{display:none;width:50%;margin:0px auto 0px;height: 40px;line-height:40px;text-align: center;position: relative;top:-50px;font-size: 20px;color:#333;background: #fff;}
    .top::before{content: '';width:0px;height:0px;border-top:20px solid transparent; border-right:20px solid #fff;border-bottom:20px solid transparent;position: absolute;left:-20px}
    .top::after{content: '';width:0px;height:0px;border-top:20px solid transparent; border-left:20px solid #fff;border-bottom:20px solid transparent;position: absolute;right:-20px}
    .login_list{padding:0px 70px;}
    .login_list li:after{content: '';display: block;clear: both;height:0;visibility: hidden}
    .login_list li{margin-top:20px;}
    .login_list input{width: 100%;height:40px;line-height:40px;border:1px solid #ddd;border-radius: 20px;padding:0px 15px;font-size: 14px;}
    .login_list .captcha{width: 50%;float:left;}
    .login_list #captcha{float:left;margin-left:30px}
    .bottom{margin-top:30px;}
    .bottom a{width: 100%;height:40px;line-height:40px;display:block;background:#00aeff;color:#fff;text-align: center;font-size: 18px;border-radius: 20px;}

</style>
    <link rel="stylesheet" type="text/css" href="${staticPath }/static/style/css/login2.css" />
</head>
<body onkeydown="enterlogin()">

<%--<div id="bg"></div>--%>
<ul class="cb-slideshow">
    <li><span style="background-image: url(http://img.dadoubk.cn/img/1508397344643000.jpg)"></span></li>
    <li><span style="background-image: url(http://img.dadoubk.cn/img/1508397529784443.jpg)"></span></li>
    <li><span style="background-image: url(http://img.dadoubk.cn/img/1508397563488981.jpg)"></span></li>
    <li><span style="background-image: url(http://img.dadoubk.cn/img/1508397596952971.jpg)"></span></li>

</ul>

<div class="layer"></div>

    <div class="login">
        <h2>Java EE Rapid Development Platform</h2>
        <div class="login_box">
            <div class="top">欢迎使用java快速开发平台请登录</div>
            <form method="post" id="loginform">
                <ul class="login_list">
                    <li><input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/></li>
                    <li><input class="ipt" type="text" name="username" placeholder="Please enter LoginName"/></li>
                    <li><input class="ipt" id="password" type="password" name="password" placeholder="Please enter Password"/></li>
                    <li><input class="captcha" type="text" name="captcha" placeholder="Please enter code"/>
                    <img id="captcha" alt="验证码" src="${path }/captcha.jpg" data-src="${path }/captcha.jpg?t=" style="vertical-align:middle;border-radius:4px;width:94.5px;height:35px;cursor:pointer;"></li>
                    <li class="bottom"><a href="javascript:;" onclick="submitForm()">Login</a></li>
                </ul>
            </form>
        </div>
    </div>

</body>
</html>
<script>

</script>
<script>
    // 判断时候在Iframe框架内,在则刷新父页面
    if (self != top) {
        parent.location.reload(true);
        if (!!(window.attachEvent && !window.opera)) {
            document.execCommand("stop");
        } else {
            window.stop();
        }
    }

    $(function(){
        // 验证码
        $("#captcha").click(function() {
            var $this = $(this);
            var url = $this.data("src") + new Date().getTime();
            $this.attr("src", url);
        });
        // 登录
        $('#loginform').form({
            url: basePath + '/adminLogin',
            onSubmit : function() {
                progressLoad();
                var isValid = $(this).form('validate');
                if(!isValid){
                    progressClose();
                }
                return isValid;
            },
            success:function(result){
                progressClose();
                result = $.parseJSON(result);
                if (result.success) {
                    window.location.href = basePath + '/adminIndex';
                }else{
                    // 刷新验证码
                    $("#captcha")[0].click();
                    showMsg(result.msg);
                }
            }
        });
    })

    function submitForm(){
        $('#loginform').submit();
    }
    //回车登录
    function enterlogin(){
        if (event.keyCode == 13){
            event.returnValue=false;
            event.cancel = true;
            $('#loginform').submit();
        }
    }
</script>
